<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<style type="text/css">
		p{
			width: 60px;
			height: 60px;
			float: left;
			margin-right: 20px;
			background-color: yellowgreen;
		}
	</style>
</head>
<body>
	<p></p>
	<p></p>
	<p></p>
	<p></p>
	<p></p>
	<p></p>
	<p></p>

	<script type="text/javascript">
		var ps = document.getElementsByTagName("p");

		for(var i = 0 ; i < ps.length ; i++){
			if(i==2)
			{
					ps[i].onclick = function(){
					this.style.backgroundColor = "yellow";
				}
			}else{
				ps[i].onclick = function(){
					this.style.backgroundColor = "red";
				}
			}
			ps[i].onmouseout = function(){
					this.style.backgroundColor = "skyblue";
			}
		}
	</script>
</body>
</html>